home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / toolkit.jar / content / mozapps / preferences / ocsp.js < prev    next >
Encoding:
JavaScript  |  2007-05-30  |  3.3 KB  |  91 lines

  1. //@line 38 "/build/buildd/xulrunner-1.9-1.9.0.14+build2+nobinonly/mozilla/toolkit/mozapps/preferences/ocsp.js"
  2.  
  3.  
  4. var gOCSPDialog = {
  5.   _certDB         : null,
  6.   _OCSPResponders : null,
  7.   _cacheRadio     : 0,
  8.  
  9.   init: function ()
  10.   {
  11.     this._certDB = Components.classes["@mozilla.org/security/x509certdb;1"]
  12.                              .getService(Components.interfaces.nsIX509CertDB);
  13.     this._OCSPResponders = this._certDB.getOCSPResponders();
  14.  
  15.     var signingCA = document.getElementById("signingCA");
  16.     const nsIOCSPResponder = Components.interfaces.nsIOCSPResponder;
  17.     for (var i = 0; i < this._OCSPResponders.length; ++i) {
  18.       var ocspEntry = this._OCSPResponders.queryElementAt(i, nsIOCSPResponder);
  19.       var menuitem = document.createElement("menuitem");
  20.       menuitem.setAttribute("value", ocspEntry.responseSigner);
  21.       menuitem.setAttribute("label", ocspEntry.responseSigner);
  22.       signingCA.firstChild.appendChild(menuitem);
  23.     }
  24.     
  25.     var signingCAPref = document.getElementById("security.OCSP.signingCA");
  26.     if (!signingCAPref.hasUserValue)
  27.       signingCA.selectedIndex = 0;
  28.     else {
  29.       // We need to initialize manually since auto-initialization is often 
  30.       // called prior to menulist population above.
  31.       signingCA.value = signingCAPref.value;
  32.     }
  33.     this.chooseServiceURL();
  34.   },
  35.   
  36.   _updateUI: function (called_by)
  37.   {
  38.     var signingCA = document.getElementById("security.OCSP.signingCA");
  39.     var serviceURL = document.getElementById("security.OCSP.URL");
  40.     var securityOCSPEnabled = document.getElementById("security.OCSP.enabled");
  41.     var requireWorkingOCSP = document.getElementById("security.OCSP.require");
  42.     var enableOCSPBox = document.getElementById("enableOCSPBox");
  43.     var certOCSP = document.getElementById("certOCSP");
  44.     var proxyOCSP = document.getElementById("proxyOCSP");
  45.  
  46.     var OCSPPrefValue = parseInt(securityOCSPEnabled.value);
  47.  
  48.     if (called_by == 0) {
  49.       // the radio button changed, or we init the stored value from prefs
  50.       enableOCSPBox.checked = (OCSPPrefValue != 0);
  51.     }
  52.     else {
  53.       // the user toggled the checkbox to enable/disable OCSP
  54.       var new_val = 0;
  55.       if (enableOCSPBox.checked) {
  56.         // now enabled. if we have a cached radio val, restore it.
  57.         // if not, use the first setting
  58.         new_val = (this._cacheRadio > 0) ? this._cacheRadio : 1;
  59.       }
  60.       else {
  61.         // now disabled. remember current value
  62.         this._cacheRadio = OCSPPrefValue;
  63.       }
  64.       securityOCSPEnabled.value = OCSPPrefValue = new_val;
  65.     }
  66.  
  67.     certOCSP.disabled = (OCSPPrefValue == 0);
  68.     proxyOCSP.disabled = (OCSPPrefValue == 0);
  69.     signingCA.disabled = serviceURL.disabled = OCSPPrefValue == 0 || OCSPPrefValue == 1;
  70.     requireWorkingOCSP.disabled = (OCSPPrefValue == 0);
  71.     
  72.     return undefined;
  73.   },
  74.   
  75.   chooseServiceURL: function ()
  76.   {
  77.     var signingCA = document.getElementById("signingCA");
  78.     var serviceURL = document.getElementById("serviceURL");
  79.     var CA = signingCA.value;
  80.     
  81.     const nsIOCSPResponder = Components.interfaces.nsIOCSPResponder;
  82.     for (var i = 0; i < this._OCSPResponders.length; ++i) {
  83.       var ocspEntry = this._OCSPResponders.queryElementAt(i, nsIOCSPResponder);
  84.       if (CA == ocspEntry.responseSigner) {
  85.         serviceURL.value = ocspEntry.serviceURL;
  86.         break;
  87.       }
  88.     }
  89.   }
  90. };
  91.